<?php
namespace backend\models\weixin;
use yii\db\ActiveRecord;

class WeiFansCount extends ActiveRecord
{
    /**
     * 表名
     */
	public static function tableName()
	{
		return 'wei_fans_count';
	}

	public function rules()
    {
        return [
            [['ref_date', 'user_source', 'new_user', 'cancel_user', 'cumulate_user'], 'required'],
        ];
    }

    /**
     * 将微信接口数据入库
     * @params array $data 
     */
    public function saveFromWei($summary, $cumulate, $key = 0)
    {
        $summary['list'][$key]['cumulate_user'] = $cumulate['list'][$key]['cumulate_user'];
        $this->setAttributes($summary['list'][$key]);
        return $this->save();
    }

    public function attributeLabels()
    {
        return [
            'id' => '',
            'ref_date'   => '',
            'user_source'  => '',
            'new_user' => '',
            'cancel_user'=> '',
            'cumulate_user' => '',
        ];
    }
}